home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / cc / dist / cexp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-12  |  34.8 KB  |  1,317 lines

  1.  
  2. /*  A Bison parser, made from ../gcc-1.37/cexp.y  */
  3.  
  4. #define    INT    258
  5. #define    CHAR    259
  6. #define    NAME    260
  7. #define    ERROR    261
  8. #define    OR    262
  9. #define    AND    263
  10. #define    EQUAL    264
  11. #define    NOTEQUAL    265
  12. #define    LEQ    266
  13. #define    GEQ    267
  14. #define    LSH    268
  15. #define    RSH    269
  16. #define    UNARY    270
  17.  
  18. #line 26 "../gcc-1.37/cexp.y"
  19.  
  20. #include "config.h"
  21. #include <setjmp.h>
  22. #include <alloca.h>
  23. /* #define YYDEBUG 1 */
  24.  
  25.   int yylex ();
  26.   void yyerror ();
  27.   int expression_value;
  28.  
  29.   static jmp_buf parse_return_error;
  30.  
  31.   /* some external tables of character types */
  32.   extern unsigned char is_idstart[], is_idchar[];
  33.  
  34. #ifndef CHAR_TYPE_SIZE
  35. #define CHAR_TYPE_SIZE BITS_PER_UNIT
  36. #endif
  37.  
  38. #line 45 "../gcc-1.37/cexp.y"
  39. typedef union {
  40.   struct constant {long value; int unsignedp;} integer;
  41.   int voidval;
  42.   char *sval;
  43. } YYSTYPE;
  44.  
  45. #ifndef YYLTYPE
  46. typedef
  47.   struct yyltype
  48.     {
  49.       int timestamp;
  50.       int first_line;
  51.       int first_column;
  52.       int last_line;
  53.       int last_column;
  54.       char *text;
  55.    }
  56.   yyltype;
  57.  
  58. #define YYLTYPE yyltype
  59. #endif
  60.  
  61. #include <stdio.h>
  62.  
  63. #ifndef __STDC__
  64. #define const
  65. #endif
  66.  
  67.  
  68.  
  69. #define    YYFINAL        61
  70. #define    YYFLAG        -32768
  71. #define    YYNTBASE    33
  72.  
  73. #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 36)
  74.  
  75. static const char yytranslate[] = {     0,
  76.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.      2,     2,    29,     2,     2,     2,    27,    14,     2,    31,
  80.     32,    25,    23,     9,    24,     2,    26,     2,     2,     2,
  81.      2,     2,     2,     2,     2,     2,     2,     8,     2,    17,
  82.      2,    18,     7,     2,     2,     2,     2,     2,     2,     2,
  83.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.      2,     2,     2,    13,     2,     2,     2,     2,     2,     2,
  86.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  88.      2,     2,     2,    12,     2,    30,     2,     2,     2,     2,
  89.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  90.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  91.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  92.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  93.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  94.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  95.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  96.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  97.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  98.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  99.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  100.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  101.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  102.      6,    10,    11,    15,    16,    19,    20,    21,    22,    28
  103. };
  104.  
  105. static const short yyrline[] = {     0,
  106.     74,    79,    80,    85,    88,    91,    93,    96,   101,   107,
  107.    118,   129,   132,   135,   141,   147,   150,   153,   159,   165,
  108.    171,   177,   180,   183,   186,   189,   192,   195,   197,   199
  109. };
  110.  
  111. static const char * const yytname[] = {     0,
  112. "error","$illegal.","INT","CHAR","NAME","ERROR","'?'","':'","','","OR",
  113. "AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'","'>'","LEQ","GEQ",
  114. "LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'","'~'",
  115. "'('","')'","start"
  116. };
  117.  
  118. static const short yyr1[] = {     0,
  119.     33,    34,    34,    35,    35,    35,    35,    35,    35,    35,
  120.     35,    35,    35,    35,    35,    35,    35,    35,    35,    35,
  121.     35,    35,    35,    35,    35,    35,    35,    35,    35,    35
  122. };
  123.  
  124. static const short yyr2[] = {     0,
  125.      1,     1,     3,     2,     2,     2,     2,     3,     3,     3,
  126.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  127.      3,     3,     3,     3,     3,     3,     5,     1,     1,     1
  128. };
  129.  
  130. static const short yydefact[] = {     0,
  131.     28,    29,    30,     0,     0,     0,     0,     0,     1,     2,
  132.      6,     4,     5,     7,     0,     0,     0,     0,     0,     0,
  133.      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  134.      0,     0,     0,     0,     0,     8,     3,     0,    26,    25,
  135.     24,    23,    22,    16,    17,    20,    21,    18,    19,    14,
  136.     15,    12,    13,     9,    10,    11,     0,    27,     0,     0,
  137.      0
  138. };
  139.  
  140. static const short yydefgoto[] = {    59,
  141.      9,    10
  142. };
  143.  
  144. static const short yypact[] = {    31,
  145. -32768,-32768,-32768,    31,    31,    31,    31,    31,     1,    77,
  146. -32768,-32768,-32768,-32768,     0,    31,    31,    31,    31,    31,
  147.     31,    31,    31,    31,    31,    31,    31,    31,    31,    31,
  148.     31,    31,    31,    31,    31,-32768,    77,    56,    94,    25,
  149.    109,   123,   136,   147,   147,   154,   154,   154,   154,   -19,
  150.    -19,    32,    32,-32768,-32768,-32768,    31,    77,    11,    33,
  151. -32768
  152. };
  153.  
  154. static const short yypgoto[] = {-32768,
  155.     48,    -4
  156. };
  157.  
  158.  
  159. #define    YYLAST        181
  160.  
  161.  
  162. static const short yytable[] = {    11,
  163.     12,    13,    14,    31,    32,    33,    34,    35,    16,    16,
  164.     60,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  165.     46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
  166.     56,    36,    61,     1,     2,     3,    20,    21,    22,    23,
  167.     24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
  168.     34,    35,    58,     4,     5,    15,    33,    34,    35,     6,
  169.      7,     8,    17,    57,     0,    18,    19,    20,    21,    22,
  170.     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
  171.     33,    34,    35,    17,     0,     0,    18,    19,    20,    21,
  172.     22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
  173.     32,    33,    34,    35,    19,    20,    21,    22,    23,    24,
  174.     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
  175.     35,    21,    22,    23,    24,    25,    26,    27,    28,    29,
  176.     30,    31,    32,    33,    34,    35,    22,    23,    24,    25,
  177.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  178.     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
  179.     33,    34,    35,    25,    26,    27,    28,    29,    30,    31,
  180.     32,    33,    34,    35,    29,    30,    31,    32,    33,    34,
  181.     35
  182. };
  183.  
  184. static const short yycheck[] = {     4,
  185.      5,     6,     7,    23,    24,    25,    26,    27,     9,     9,
  186.      0,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  187.     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
  188.     35,    32,     0,     3,     4,     5,    12,    13,    14,    15,
  189.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  190.     26,    27,    57,    23,    24,     8,    25,    26,    27,    29,
  191.     30,    31,     7,     8,    -1,    10,    11,    12,    13,    14,
  192.     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  193.     25,    26,    27,     7,    -1,    -1,    10,    11,    12,    13,
  194.     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
  195.     24,    25,    26,    27,    11,    12,    13,    14,    15,    16,
  196.     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
  197.     27,    13,    14,    15,    16,    17,    18,    19,    20,    21,
  198.     22,    23,    24,    25,    26,    27,    14,    15,    16,    17,
  199.     18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
  200.     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
  201.     25,    26,    27,    17,    18,    19,    20,    21,    22,    23,
  202.     24,    25,    26,    27,    21,    22,    23,    24,    25,    26,
  203.     27
  204. };
  205. #define YYPURE 1
  206.  
  207. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  208. #line 3 "bison.simple"
  209.  
  210. /* Skeleton output parser for bison,
  211.    Copyright (C) 1984 Bob Corbett and Richard Stallman
  212.  
  213.    This program is free software; you can redistribute it and/or modify
  214.    it under the terms of the GNU General Public License as published by
  215.    the Free Software Foundation; either version 1, or (at your option)
  216.    any later version.
  217.  
  218.    This program is distributed in the hope that it will be useful,
  219.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  220.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  221.    GNU General Public License for more details.
  222.  
  223.    You should have received a copy of the GNU General Public License
  224.    along with this program; if not, write to the Free Software
  225.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  226.  
  227.  
  228. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
  229. #include <alloca.h>
  230. #endif
  231.  
  232. /* This is the parser code that is written into each bison parser
  233.   when the %semantic_parser declaration is not specified in the grammar.
  234.   It was written by Richard Stallman by simplifying the hairy parser
  235.   used when %semantic_parser is specified.  */
  236.  
  237. /* Note: there must be only one dollar sign in this file.
  238.    It is replaced by the list of actions, each action
  239.    as one case of the switch.  */
  240.  
  241. #define yyerrok        (yyerrstatus = 0)
  242. #define yyclearin    (yychar = YYEMPTY)
  243. #define YYEMPTY        -2
  244. #define YYEOF        0
  245. #define YYFAIL        goto yyerrlab;
  246. #define YYACCEPT    return(0)
  247. #define YYABORT     return(1)
  248. #define YYERROR        goto yyerrlab
  249.  
  250. #define YYTERROR    1
  251. #define YYERRCODE    256
  252.  
  253. #ifndef YYIMPURE
  254. #define YYLEX        yylex()
  255. #endif
  256.  
  257. #ifndef YYPURE
  258. #define YYLEX        yylex(&yylval, &yylloc)
  259. #endif
  260.  
  261. /* If nonreentrant, generate the variables here */
  262.  
  263. #ifndef YYIMPURE
  264.  
  265. int    yychar;            /*  the lookahead symbol        */
  266. YYSTYPE    yylval;            /*  the semantic value of the        */
  267.                 /*  lookahead symbol            */
  268.  
  269. YYLTYPE yylloc;            /*  location data for the lookahead    */
  270.                 /*  symbol                */
  271.  
  272. int yynerrs;            /*  number of parse errors so far       */
  273. #endif  /* YYIMPURE */
  274.  
  275. #if YYDEBUG != 0
  276. int yydebug;            /*  nonzero means print parse trace    */
  277. /* Since this is uninitialized, it does not stop multiple parsers
  278.    from coexisting.  */
  279. #endif
  280.  
  281. /*  YYMAXDEPTH indicates the initial size of the parser's stacks    */
  282.  
  283. #ifndef    YYMAXDEPTH
  284. #define YYMAXDEPTH 200
  285. #endif
  286.  
  287. /*  YYMAXLIMIT is the maximum size the stacks can grow to
  288.     (effective only if the built-in stack extension method is used).  */
  289.  
  290. #ifndef YYMAXLIMIT
  291. #define YYMAXLIMIT 10000
  292. #endif
  293.  
  294.  
  295. #line 90 "bison.simple"
  296. int
  297. yyparse()
  298. {
  299.   register int yystate;
  300.   register int yyn;
  301.   register short *yyssp;
  302.   register YYSTYPE *yyvsp;
  303.   YYLTYPE *yylsp;
  304.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  305.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  306.  
  307.   short    yyssa[YYMAXDEPTH];    /*  the state stack            */
  308.   YYSTYPE yyvsa[YYMAXDEPTH];    /*  the semantic value stack        */
  309.   YYLTYPE yylsa[YYMAXDEPTH];    /*  the location stack            */
  310.  
  311.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  312.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  313.   YYLTYPE *yyls = yylsa;
  314.  
  315.   int yymaxdepth = YYMAXDEPTH;
  316.  
  317. #ifndef YYPURE
  318.   int yychar;
  319.   YYSTYPE yylval;
  320.   YYLTYPE yylloc;
  321.   int yynerrs;
  322. #endif
  323.  
  324.   YYSTYPE yyval;        /*  the variable used to return        */
  325.                 /*  semantic values from the action    */
  326.                 /*  routines                */
  327.  
  328.   int yylen;
  329.  
  330. #if YYDEBUG != 0
  331.   if (yydebug)
  332.     fprintf(stderr, "Starting parse\n");
  333. #endif
  334.  
  335.   yystate = 0;
  336.   yyerrstatus = 0;
  337.   yynerrs = 0;
  338.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  339.  
  340.   /* Initialize stack pointers.
  341.      Waste one element of value and location stack
  342.      so that they stay on the same level as the state stack.  */
  343.  
  344.   yyssp = yyss - 1;
  345.   yyvsp = yyvs;
  346.   yylsp = yyls;
  347.  
  348. /* Push a new state, which is found in  yystate  .  */
  349. /* In all cases, when you get here, the value and location stacks
  350.    have just been pushed. so pushing a state here evens the stacks.  */
  351. yynewstate:
  352.  
  353.   *++yyssp = yystate;
  354.  
  355.   if (yyssp >= yyss + yymaxdepth - 1)
  356.     {
  357.       /* Give user a chance to reallocate the stack */
  358.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  359.       YYSTYPE *yyvs1 = yyvs;
  360.       YYLTYPE *yyls1 = yyls;
  361.       short *yyss1 = yyss;
  362.  
  363.       /* Get the current used size of the three stacks, in elements.  */
  364.       int size = yyssp - yyss + 1;
  365.  
  366. #ifdef yyoverflow
  367.       /* Each stack pointer address is followed by the size of
  368.      the data in use in that stack, in bytes.  */
  369.       yyoverflow("parser stack overflow",
  370.          &yyss1, size * sizeof (*yyssp),
  371.          &yyvs1, size * sizeof (*yyvsp),
  372.          &yyls1, size * sizeof (*yylsp),
  373.          &yymaxdepth);
  374.  
  375.       yyss = yyss1; yyvs = yyvs1; yyls = yyls1;
  376. #else /* no yyoverflow */
  377.       /* Extend the stack our own way.  */
  378.       if (yymaxdepth >= YYMAXLIMIT)
  379.     yyerror("parser stack overflow");
  380.       yymaxdepth *= 2;
  381.       if (yymaxdepth > YYMAXLIMIT)
  382.     yymaxdepth = YYMAXLIMIT;
  383.       yyss = (short *) alloca (yymaxdepth * sizeof (*yyssp));
  384.       bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  385.       yyvs = (YYSTYPE *) alloca (yymaxdepth * sizeof (*yyvsp));
  386.       bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  387. #ifdef YYLSP_NEEDED
  388.       yyls = (YYLTYPE *) alloca (yymaxdepth * sizeof (*yylsp));
  389.       bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  390. #endif
  391. #endif /* no yyoverflow */
  392.  
  393.       yyssp = yyss + size - 1;
  394.       yyvsp = yyvs + size - 1;
  395. #ifdef YYLSP_NEEDED
  396.       yylsp = yyls + size - 1;
  397. #endif
  398.  
  399. #if YYDEBUG != 0
  400.       if (yydebug)
  401.     fprintf(stderr, "Stack size increased to %d\n", yymaxdepth);
  402. #endif
  403.  
  404.       if (yyssp >= yyss + yymaxdepth - 1)
  405.     YYABORT;
  406.     }
  407.  
  408. #if YYDEBUG != 0
  409.   if (yydebug)
  410.     fprintf(stderr, "Entering state %d\n", yystate);
  411. #endif
  412.  
  413. /* Do appropriate processing given the current state.  */
  414. /* Read a lookahead token if we need one and don't already have one.  */
  415. yyresume:
  416.  
  417.   /* First try to decide what to do without reference to lookahead token.  */
  418.  
  419.   yyn = yypact[yystate];
  420.   if (yyn == YYFLAG)
  421.     goto yydefault;
  422.  
  423.   /* Not known => get a lookahead token if don't already have one.  */
  424.  
  425.   /* yychar is either YYEMPTY or YYEOF
  426.      or a valid token in external form.  */
  427.  
  428.   if (yychar == YYEMPTY)
  429.     {
  430. #if YYDEBUG != 0
  431.       if (yydebug)
  432.     fprintf(stderr, "Reading a token: ");
  433. #endif
  434.       yychar = YYLEX;
  435.     }
  436.  
  437.   /* Convert token to internal form (in yychar1) for indexing tables with */
  438.  
  439.   if (yychar <= 0)        /* This means end of input. */
  440.     {
  441.       yychar1 = 0;
  442.       yychar = YYEOF;        /* Don't call YYLEX any more */
  443.  
  444. #if YYDEBUG != 0
  445.       if (yydebug)
  446.     fprintf(stderr, "Now at end of input.\n");
  447. #endif
  448.     }
  449.   else
  450.     {
  451.       yychar1 = YYTRANSLATE(yychar);
  452.  
  453. #if YYDEBUG != 0
  454.       if (yydebug)
  455.     fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
  456. #endif
  457.     }
  458.  
  459.   yyn += yychar1;
  460.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  461.     goto yydefault;
  462.  
  463.   yyn = yytable[yyn];
  464.  
  465.   /* yyn is what to do for this token type in this state.
  466.      Negative => reduce, -yyn is rule number.
  467.      Positive => shift, yyn is new state.
  468.        New state is final state => don't bother to shift,
  469.        just return success.
  470.      0, or most negative number => error.  */
  471.  
  472.   if (yyn < 0)
  473.     {
  474.       if (yyn == YYFLAG)
  475.     goto yyerrlab;
  476.       yyn = -yyn;
  477.       goto yyreduce;
  478.     }
  479.   else if (yyn == 0)
  480.     goto yyerrlab;
  481.  
  482.   if (yyn == YYFINAL)
  483.     YYACCEPT;
  484.  
  485.   /* Shift the lookahead token.  */
  486.  
  487. #if YYDEBUG != 0
  488.   if (yydebug)
  489.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  490. #endif
  491.  
  492.   /* Discard the token being shifted unless it is eof.  */
  493.   if (yychar != YYEOF)
  494.     yychar = YYEMPTY;
  495.  
  496.   *++yyvsp = yylval;
  497. #ifdef YYLSP_NEEDED
  498.   *++yylsp = yylloc;
  499. #endif
  500.  
  501.   /* count tokens shifted since error; after three, turn off error status.  */
  502.   if (yyerrstatus) yyerrstatus--;
  503.  
  504.   yystate = yyn;
  505.   goto yynewstate;
  506.  
  507. /* Do the default action for the current state.  */
  508. yydefault:
  509.  
  510.   yyn = yydefact[yystate];
  511.   if (yyn == 0)
  512.     goto yyerrlab;
  513.  
  514. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  515. yyreduce:
  516.   yylen = yyr2[yyn];
  517.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  518.  
  519. #if YYDEBUG != 0
  520.   if (yydebug)
  521.     {
  522.       if (yylen == 1)
  523.     fprintf (stderr, "Reducing 1 value via line %d, ",
  524.          yyrline[yyn]);
  525.       else
  526.     fprintf (stderr, "Reducing %d values via line %d, ",
  527.          yylen, yyrline[yyn]);
  528.     }
  529. #endif
  530.  
  531.  
  532.   switch (yyn) {
  533.  
  534. case 1:
  535. #line 75 "../gcc-1.37/cexp.y"
  536. { expression_value = yyvsp[0].integer.value; ;
  537.     break;}
  538. case 3:
  539. #line 81 "../gcc-1.37/cexp.y"
  540. { yyval.integer = yyvsp[0].integer; ;
  541.     break;}
  542. case 4:
  543. #line 86 "../gcc-1.37/cexp.y"
  544. { yyval.integer.value = - yyvsp[0].integer.value;
  545.               yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ;
  546.     break;}
  547. case 5:
  548. #line 89 "../gcc-1.37/cexp.y"
  549. { yyval.integer.value = ! yyvsp[0].integer.value;
  550.               yyval.integer.unsignedp = 0; ;
  551.     break;}
  552. case 6:
  553. #line 92 "../gcc-1.37/cexp.y"
  554. { yyval.integer = yyvsp[0].integer; ;
  555.     break;}
  556. case 7:
  557. #line 94 "../gcc-1.37/cexp.y"
  558. { yyval.integer.value = ~ yyvsp[0].integer.value;
  559.               yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ;
  560.     break;}
  561. case 8:
  562. #line 97 "../gcc-1.37/cexp.y"
  563. { yyval.integer = yyvsp[-1].integer; ;
  564.     break;}
  565. case 9:
  566. #line 102 "../gcc-1.37/cexp.y"
  567. { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
  568.               if (yyval.integer.unsignedp)
  569.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value * yyvsp[0].integer.value;
  570.               else
  571.                 yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; ;
  572.     break;}
  573. case 10:
  574. #line 108 "../gcc-1.37/cexp.y"
  575. { if (yyvsp[0].integer.value == 0)
  576.                 {
  577.                   error ("division by zero in #if");
  578.                   yyvsp[0].integer.value = 1;
  579.                 }
  580.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
  581.               if (yyval.integer.unsignedp)
  582.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value / yyvsp[0].integer.value;
  583.               else
  584.                 yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; ;
  585.     break;}
  586. case 11:
  587. #line 119 "../gcc-1.37/cexp.y"
  588. { if (yyvsp[0].integer.value == 0)
  589.                 {
  590.                   error ("division by zero in #if");
  591.                   yyvsp[0].integer.value = 1;
  592.                 }
  593.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
  594.               if (yyval.integer.unsignedp)
  595.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value % yyvsp[0].integer.value;
  596.               else
  597.                 yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; ;
  598.     break;}
  599. case 12:
  600. #line 130 "../gcc-1.37/cexp.y"
  601. { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value;
  602.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
  603.     break;}
  604. case 13:
  605. #line 133 "../gcc-1.37/cexp.y"
  606. { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value;
  607.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
  608.     break;}
  609. case 14:
  610. #line 136 "../gcc-1.37/cexp.y"
  611. { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp;
  612.               if (yyval.integer.unsignedp)
  613.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value << yyvsp[0].integer.value;
  614.               else
  615.                 yyval.integer.value = yyvsp[-2].integer.value << yyvsp[0].integer.value; ;
  616.     break;}
  617. case 15:
  618. #line 142 "../gcc-1.37/cexp.y"
  619. { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp;
  620.               if (yyval.integer.unsignedp)
  621.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value >> yyvsp[0].integer.value;
  622.               else
  623.                 yyval.integer.value = yyvsp[-2].integer.value >> yyvsp[0].integer.value; ;
  624.     break;}
  625. case 16:
  626. #line 148 "../gcc-1.37/cexp.y"
  627. { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value);
  628.               yyval.integer.unsignedp = 0; ;
  629.     break;}
  630. case 17:
  631. #line 151 "../gcc-1.37/cexp.y"
  632. { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value);
  633.               yyval.integer.unsignedp = 0; ;
  634.     break;}
  635. case 18:
  636. #line 154 "../gcc-1.37/cexp.y"
  637. { yyval.integer.unsignedp = 0;
  638.               if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
  639.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value <= yyvsp[0].integer.value;
  640.               else
  641.                 yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; ;
  642.     break;}
  643. case 19:
  644. #line 160 "../gcc-1.37/cexp.y"
  645. { yyval.integer.unsignedp = 0;
  646.               if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
  647.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value >= yyvsp[0].integer.value;
  648.               else
  649.                 yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; ;
  650.     break;}
  651. case 20:
  652. #line 166 "../gcc-1.37/cexp.y"
  653. { yyval.integer.unsignedp = 0;
  654.               if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
  655.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value < yyvsp[0].integer.value;
  656.               else
  657.                 yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; ;
  658.     break;}
  659. case 21:
  660. #line 172 "../gcc-1.37/cexp.y"
  661. { yyval.integer.unsignedp = 0;
  662.               if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
  663.                 yyval.integer.value = (unsigned) yyvsp[-2].integer.value > yyvsp[0].integer.value;
  664.               else
  665.                 yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; ;
  666.     break;}
  667. case 22:
  668. #line 178 "../gcc-1.37/cexp.y"
  669. { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value;
  670.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
  671.     break;}
  672. case 23:
  673. #line 181 "../gcc-1.37/cexp.y"
  674. { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value;
  675.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
  676.     break;}
  677. case 24:
  678. #line 184 "../gcc-1.37/cexp.y"
  679. { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value;
  680.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
  681.     break;}
  682. case 25:
  683. #line 187 "../gcc-1.37/cexp.y"
  684. { yyval.integer.value = (yyvsp[-2].integer.value && yyvsp[0].integer.value);
  685.               yyval.integer.unsignedp = 0; ;
  686.     break;}
  687. case 26:
  688. #line 190 "../gcc-1.37/cexp.y"
  689. { yyval.integer.value = (yyvsp[-2].integer.value || yyvsp[0].integer.value);
  690.               yyval.integer.unsignedp = 0; ;
  691.     break;}
  692. case 27:
  693. #line 193 "../gcc-1.37/cexp.y"
  694. { yyval.integer.value = yyvsp[-4].integer.value ? yyvsp[-2].integer.value : yyvsp[0].integer.value;
  695.               yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
  696.     break;}
  697. case 28:
  698. #line 196 "../gcc-1.37/cexp.y"
  699. { yyval.integer = yylval.integer; ;
  700.     break;}
  701. case 29:
  702. #line 198 "../gcc-1.37/cexp.y"
  703. { yyval.integer = yylval.integer; ;
  704.     break;}
  705. case 30:
  706. #line 200 "../gcc-1.37/cexp.y"
  707. { yyval.integer.value = 0;
  708.               yyval.integer.unsignedp = 0; ;
  709.     break;}
  710. }
  711.    /* the action file gets copied in in place of this dollarsign */
  712. #line 327 "bison.simple"
  713.  
  714.   yyvsp -= yylen;
  715.   yyssp -= yylen;
  716. #ifdef YYLSP_NEEDED
  717.   yylsp -= yylen;
  718. #endif
  719.  
  720. #if YYDEBUG != 0
  721.   if (yydebug)
  722.     {
  723.       short *ssp1 = yyss - 1;
  724.       fprintf (stderr, "state stack now");
  725.       while (ssp1 != yyssp)
  726.     fprintf (stderr, " %d", *++ssp1);
  727.       fprintf (stderr, "\n");
  728.     }
  729. #endif
  730.  
  731.   *++yyvsp = yyval;
  732.  
  733. #ifdef YYLSP_NEEDED
  734.   yylsp++;
  735.   if (yylen == 0)
  736.     {
  737.       yylsp->first_line = yylloc.first_line;
  738.       yylsp->first_column = yylloc.first_column;
  739.       yylsp->last_line = (yylsp-1)->last_line;
  740.       yylsp->last_column = (yylsp-1)->last_column;
  741.       yylsp->text = 0;
  742.     }
  743.   else
  744.     {
  745.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  746.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  747.     }
  748. #endif
  749.  
  750.   /* Now "shift" the result of the reduction.
  751.      Determine what state that goes to,
  752.      based on the state we popped back to
  753.      and the rule number reduced by.  */
  754.  
  755.   yyn = yyr1[yyn];
  756.  
  757.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  758.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  759.     yystate = yytable[yystate];
  760.   else
  761.     yystate = yydefgoto[yyn - YYNTBASE];
  762.  
  763.   goto yynewstate;
  764.  
  765. yyerrlab:   /* here on detecting error */
  766.  
  767.   if (! yyerrstatus)
  768.     /* If not already recovering from an error, report this error.  */
  769.     {
  770.       ++yynerrs;
  771.       yyerror("parse error");
  772.     }
  773.  
  774.   if (yyerrstatus == 3)
  775.     {
  776.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  777.  
  778.       /* return failure if at end of input */
  779.       if (yychar == YYEOF)
  780.     YYABORT;
  781.  
  782. #if YYDEBUG != 0
  783.       if (yydebug)
  784.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  785. #endif
  786.  
  787.       yychar = YYEMPTY;
  788.     }
  789.  
  790.   /* Else will try to reuse lookahead token
  791.      after shifting the error token.  */
  792.  
  793.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  794.  
  795.   goto yyerrhandle;
  796.  
  797. yyerrdefault:  /* current state does not do anything special for the error token. */
  798.  
  799. #if 0
  800.   /* This is wrong; only states that explicitly want error tokens
  801.      should shift them.  */
  802.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  803.   if (yyn) goto yydefault;
  804. #endif
  805.  
  806. yyerrpop:   /* pop the current state because it cannot handle the error token */
  807.  
  808.   if (yyssp == yyss) YYABORT;
  809.   yyvsp--;
  810.   yystate = *--yyssp;
  811. #ifdef YYLSP_NEEDED
  812.   yylsp--;
  813. #endif
  814.  
  815. #if YYDEBUG != 0
  816.   if (yydebug)
  817.     {
  818.       short *ssp1 = yyss - 1;
  819.       fprintf (stderr, "Error: state stack now");
  820.       while (ssp1 != yyssp)
  821.     fprintf (stderr, " %d", *++ssp1);
  822.       fprintf (stderr, "\n");
  823.     }
  824. #endif
  825.  
  826. yyerrhandle:
  827.  
  828.   yyn = yypact[yystate];
  829.   if (yyn == YYFLAG)
  830.     goto yyerrdefault;
  831.  
  832.   yyn += YYTERROR;
  833.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  834.     goto yyerrdefault;
  835.  
  836.   yyn = yytable[yyn];
  837.   if (yyn < 0)
  838.     {
  839.       if (yyn == YYFLAG)
  840.     goto yyerrpop;
  841.       yyn = -yyn;
  842.       goto yyreduce;
  843.     }
  844.   else if (yyn == 0)
  845.     goto yyerrpop;
  846.  
  847.   if (yyn == YYFINAL)
  848.     YYACCEPT;
  849.  
  850. #if YYDEBUG != 0
  851.   if (yydebug)
  852.     fprintf(stderr, "Shifting error token, ");
  853. #endif
  854.  
  855.   *++yyvsp = yylval;
  856. #ifdef YYLSP_NEEDED
  857.   *++yylsp = yylloc;
  858. #endif
  859.  
  860.   yystate = yyn;
  861.   goto yynewstate;
  862. }
  863. #line 203 "../gcc-1.37/cexp.y"
  864.  
  865.  
  866. /* During parsing of a C expression, the pointer to the next character
  867.    is in this variable.  */
  868.  
  869. static char *lexptr;
  870.  
  871. /* Take care of parsing a number (anything that starts with a digit).
  872.    Set yylval and return the token type; update lexptr.
  873.    LEN is the number of characters in it.  */
  874.  
  875. /* maybe needs to actually deal with floating point numbers */
  876.  
  877. int
  878. parse_number (olen)
  879.      int olen;
  880. {
  881.   register char *p = lexptr;
  882.   register long n = 0;
  883.   register int c;
  884.   register int base = 10;
  885.   register int len = olen;
  886.  
  887.   for (c = 0; c < len; c++)
  888.     if (p[c] == '.') {
  889.       /* It's a float since it contains a point.  */
  890.       yyerror ("floating point numbers not allowed in #if expressions");
  891.       return ERROR;
  892.     }
  893.  
  894.   yylval.integer.unsignedp = 0;
  895.  
  896.   if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) {
  897.     p += 2;
  898.     base = 16;
  899.     len -= 2;
  900.   }
  901.   else if (*p == '0')
  902.     base = 8;
  903.  
  904.   while (len > 0) {
  905.     c = *p++;
  906.     len--;
  907.     if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
  908.  
  909.     if (c >= '0' && c <= '9') {
  910.       n *= base;
  911.       n += c - '0';
  912.     } else if (base == 16 && c >= 'a' && c <= 'f') {
  913.       n *= base;
  914.       n += c - 'a' + 10;
  915.     } else {
  916.       /* `l' means long, and `u' means unsigned.  */
  917.       while (1) {
  918.     if (c == 'l' || c == 'L')
  919.       ;
  920.     else if (c == 'u' || c == 'U')
  921.       yylval.integer.unsignedp = 1;
  922.     else
  923.       break;
  924.  
  925.     if (len == 0)
  926.       break;
  927.     c = *p++;
  928.     len--;
  929.       }
  930.       /* Don't look for any more digits after the suffixes.  */
  931.       break;
  932.     }
  933.   }
  934.  
  935.   if (len != 0) {
  936.     yyerror ("Invalid number in #if expression");
  937.     return ERROR;
  938.   }
  939.  
  940.   /* If too big to be signed, consider it unsigned.  */
  941.   if (n < 0)
  942.     yylval.integer.unsignedp = 1;
  943.  
  944.   lexptr = p;
  945.   yylval.integer.value = n;
  946.   return INT;
  947. }
  948.  
  949. struct token {
  950.   char *operator;
  951.   int token;
  952. };
  953.  
  954. #ifndef NULL
  955. #define NULL 0
  956. #endif
  957.  
  958. static struct token tokentab2[] = {
  959.   {"&&", AND},
  960.   {"||", OR},
  961.   {"<<", LSH},
  962.   {">>", RSH},
  963.   {"==", EQUAL},
  964.   {"!=", NOTEQUAL},
  965.   {"<=", LEQ},
  966.   {">=", GEQ},
  967.   {NULL, ERROR}
  968. };
  969.  
  970. /* Read one token, getting characters through lexptr.  */
  971.  
  972. int
  973. yylex ()
  974. {
  975.   register int c;
  976.   register int namelen;
  977.   register char *tokstart;
  978.   register struct token *toktab;
  979.  
  980.  retry:
  981.  
  982.   tokstart = lexptr;
  983.   c = *tokstart;
  984.   /* See if it is a special token of length 2.  */
  985.   for (toktab = tokentab2; toktab->operator != NULL; toktab++)
  986.     if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
  987.       lexptr += 2;
  988.       return toktab->token;
  989.     }
  990.  
  991.   switch (c) {
  992.   case 0:
  993.     return 0;
  994.     
  995.   case ' ':
  996.   case '\t':
  997.   case '\n':
  998.     lexptr++;
  999.     goto retry;
  1000.     
  1001.   case '\'':
  1002.     lexptr++;
  1003.     c = *lexptr++;
  1004.     if (c == '\\')
  1005.       c = parse_escape (&lexptr);
  1006.  
  1007.     /* Sign-extend the constant if chars are signed on target machine.  */
  1008.     {
  1009.       if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1)
  1010.       || ((c >> (CHAR_TYPE_SIZE - 1)) & 1) == 0)
  1011.     yylval.integer.value = c & ((1 << CHAR_TYPE_SIZE) - 1);
  1012.       else
  1013.     yylval.integer.value = c | ~((1 << CHAR_TYPE_SIZE) - 1);
  1014.     }
  1015.  
  1016.     yylval.integer.unsignedp = 0;
  1017.     c = *lexptr++;
  1018.     if (c != '\'') {
  1019.       yyerror ("Invalid character constant in #if");
  1020.       return ERROR;
  1021.     }
  1022.     
  1023.     return CHAR;
  1024.  
  1025.     /* some of these chars are invalid in constant expressions;
  1026.        maybe do something about them later */
  1027.   case '/':
  1028.   case '+':
  1029.   case '-':
  1030.   case '*':
  1031.   case '%':
  1032.   case '|':
  1033.   case '&':
  1034.   case '^':
  1035.   case '~':
  1036.   case '!':
  1037.   case '@':
  1038.   case '<':
  1039.   case '>':
  1040.   case '(':
  1041.   case ')':
  1042.   case '[':
  1043.   case ']':
  1044.   case '.':
  1045.   case '?':
  1046.   case ':':
  1047.   case '=':
  1048.   case '{':
  1049.   case '}':
  1050.   case ',':
  1051.     lexptr++;
  1052.     return c;
  1053.     
  1054.   case '"':
  1055.     yyerror ("double quoted strings not allowed in #if expressions");
  1056.     return ERROR;
  1057.   }
  1058.   if (c >= '0' && c <= '9') {
  1059.     /* It's a number */
  1060.     for (namelen = 0;
  1061.      c = tokstart[namelen], is_idchar[c] || c == '.'; 
  1062.      namelen++)
  1063.       ;
  1064.     return parse_number (namelen);
  1065.   }
  1066.   
  1067.   if (!is_idstart[c]) {
  1068.     yyerror ("Invalid token in expression");
  1069.     return ERROR;
  1070.   }
  1071.   
  1072.   /* It is a name.  See how long it is.  */
  1073.   
  1074.   for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
  1075.     ;
  1076.   
  1077.   lexptr += namelen;
  1078.   return NAME;
  1079. }
  1080.  
  1081.  
  1082. /* Parse a C escape sequence.  STRING_PTR points to a variable
  1083.    containing a pointer to the string to parse.  That pointer
  1084.    is updated past the characters we use.  The value of the
  1085.    escape sequence is returned.
  1086.  
  1087.    A negative value means the sequence \ newline was seen,
  1088.    which is supposed to be equivalent to nothing at all.
  1089.  
  1090.    If \ is followed by a null character, we return a negative
  1091.    value and leave the string pointer pointing at the null character.
  1092.  
  1093.    If \ is followed by 000, we return 0 and leave the string pointer
  1094.    after the zeros.  A value of 0 does not mean end of string.  */
  1095.  
  1096. int
  1097. parse_escape (string_ptr)
  1098.      char **string_ptr;
  1099. {
  1100.   register int c = *(*string_ptr)++;
  1101.   switch (c)
  1102.     {
  1103.     case 'a':
  1104.       return TARGET_BELL;
  1105.     case 'b':
  1106.       return TARGET_BS;
  1107.     case 'e':
  1108.       return 033;
  1109.     case 'f':
  1110.       return TARGET_FF;
  1111.     case 'n':
  1112.       return TARGET_NEWLINE;
  1113.     case 'r':
  1114.       return TARGET_CR;
  1115.     case 't':
  1116.       return TARGET_TAB;
  1117.     case 'v':
  1118.       return TARGET_VT;
  1119.     case '\n':
  1120.       return -2;
  1121.     case 0:
  1122.       (*string_ptr)--;
  1123.       return 0;
  1124.     case '^':
  1125.       c = *(*string_ptr)++;
  1126.       if (c == '\\')
  1127.     c = parse_escape (string_ptr);
  1128.       if (c == '?')
  1129.     return 0177;
  1130.       return (c & 0200) | (c & 037);
  1131.       
  1132.     case '0':
  1133.     case '1':
  1134.     case '2':
  1135.     case '3':
  1136.     case '4':
  1137.     case '5':
  1138.     case '6':
  1139.     case '7':
  1140.       {
  1141.     register int i = c - '0';
  1142.     register int count = 0;
  1143.     while (++count < 3)
  1144.       {
  1145.         c = *(*string_ptr)++;
  1146.         if (c >= '0' && c <= '7')
  1147.           i = (i << 3) + c - '0';
  1148.         else
  1149.           {
  1150.         (*string_ptr)--;
  1151.         break;
  1152.           }
  1153.       }
  1154.     if ((i & ~((1 << CHAR_TYPE_SIZE) - 1)) != 0)
  1155.       {
  1156.         i &= (1 << CHAR_TYPE_SIZE) - 1;
  1157.         warning ("octal character constant does not fit in a byte");
  1158.       }
  1159.     return i;
  1160.       }
  1161.     case 'x':
  1162.       {
  1163.     register int i = 0;
  1164.     register int count = 0;
  1165.     for (;;)
  1166.       {
  1167.         c = *(*string_ptr)++;
  1168.         if (c >= '0' && c <= '9')
  1169.           i = (i << 4) + c - '0';
  1170.         else if (c >= 'a' && c <= 'f')
  1171.           i = (i << 4) + c - 'a' + 10;
  1172.         else if (c >= 'A' && c <= 'F')
  1173.           i = (i << 4) + c - 'A' + 10;
  1174.         else
  1175.           {
  1176.         (*string_ptr)--;
  1177.         break;
  1178.           }
  1179.       }
  1180.     if ((i & ~((1 << BITS_PER_UNIT) - 1)) != 0)
  1181.       {
  1182.         i &= (1 << BITS_PER_UNIT) - 1;
  1183.         warning ("hex character constant does not fit in a byte");
  1184.       }
  1185.     return i;
  1186.       }
  1187.     default:
  1188.       return c;
  1189.     }
  1190. }
  1191.  
  1192. void
  1193. yyerror (s)
  1194.      char *s;
  1195. {
  1196.   error (s);
  1197.   longjmp (parse_return_error, 1);
  1198. }
  1199.  
  1200. /* This page contains the entry point to this file.  */
  1201.  
  1202. /* Parse STRING as an expression, and complain if this fails
  1203.    to use up all of the contents of STRING.  */
  1204. /* We do not support C comments.  They should be removed before
  1205.    this function is called.  */
  1206.  
  1207. int
  1208. parse_c_expression (string)
  1209.      char *string;
  1210. {
  1211.   lexptr = string;
  1212.   
  1213.   if (lexptr == 0 || *lexptr == 0) {
  1214.     error ("empty #if expression");
  1215.     return 0;            /* don't include the #if group */
  1216.   }
  1217.  
  1218.   /* if there is some sort of scanning error, just return 0 and assume
  1219.      the parsing routine has printed an error message somewhere.
  1220.      there is surely a better thing to do than this.     */
  1221.   if (setjmp (parse_return_error))
  1222.     return 0;
  1223.  
  1224.   if (yyparse ())
  1225.     return 0;            /* actually this is never reached
  1226.                    the way things stand. */
  1227.   if (*lexptr)
  1228.     error ("Junk after end of expression.");
  1229.  
  1230.   return expression_value;    /* set by yyparse () */
  1231. }
  1232.  
  1233. #ifdef TEST_EXP_READER
  1234. /* main program, for testing purposes. */
  1235. main ()
  1236. {
  1237.   int n, c;
  1238.   char buf[1024];
  1239.   extern int yydebug;
  1240. /*
  1241.   yydebug = 1;
  1242. */
  1243.   initialize_random_junk ();
  1244.  
  1245.   for (;;) {
  1246.     printf ("enter expression: ");
  1247.     n = 0;
  1248.     while ((buf[n] = getchar ()) != '\n' && buf[n] != EOF)
  1249.       n++;
  1250.     if (buf[n] == EOF)
  1251.       break;
  1252.     buf[n] = '\0';
  1253.     printf ("parser returned %d\n", parse_c_expression (buf));
  1254.   }
  1255. }
  1256.  
  1257. /* table to tell if char can be part of a C identifier. */
  1258. unsigned char is_idchar[256];
  1259. /* table to tell if char can be first char of a c identifier. */
  1260. unsigned char is_idstart[256];
  1261. /* table to tell if c is horizontal space.  isspace () thinks that
  1262.    newline is space; this is not a good idea for this program. */
  1263. char is_hor_space[256];
  1264.  
  1265. /*
  1266.  * initialize random junk in the hash table and maybe other places
  1267.  */
  1268. initialize_random_junk ()
  1269. {
  1270.   register int i;
  1271.  
  1272.   /*
  1273.    * Set up is_idchar and is_idstart tables.  These should be
  1274.    * faster than saying (is_alpha (c) || c == '_'), etc.
  1275.    * Must do set up these things before calling any routines tthat
  1276.    * refer to them.
  1277.    */
  1278.   for (i = 'a'; i <= 'z'; i++) {
  1279.     ++is_idchar[i - 'a' + 'A'];
  1280.     ++is_idchar[i];
  1281.     ++is_idstart[i - 'a' + 'A'];
  1282.     ++is_idstart[i];
  1283.   }
  1284.   for (i = '0'; i <= '9'; i++)
  1285.     ++is_idchar[i];
  1286.   ++is_idchar['_'];
  1287.   ++is_idstart['_'];
  1288. #if DOLLARS_IN_IDENTIFIERS
  1289.   ++is_idchar['$'];
  1290.   ++is_idstart['$'];
  1291. #endif
  1292.  
  1293.   /* horizontal space table */
  1294.   ++is_hor_space[' '];
  1295.   ++is_hor_space['\t'];
  1296. }
  1297.  
  1298. error (msg)
  1299. {
  1300.   printf ("error: %s\n", msg);
  1301. }
  1302.  
  1303. warning (msg)
  1304. {
  1305.   printf ("warning: %s\n", msg);
  1306. }
  1307.  
  1308. struct hashnode *
  1309. lookup (name, len, hash)
  1310.      char *name;
  1311.      int len;
  1312.      int hash;
  1313. {
  1314.   return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1);
  1315. }
  1316. #endif
  1317.